import json
import unittest
import ddt

from Base.BaseSetting import TestData_dir
from Business.Stu_Mamagement_pzy import WoniuBoss
@ddt.ddt
class wonius(unittest.TestCase):
    def setUp(self) -> None:
        self.run = WoniuBoss()

    # def tearDown(self) -> None:
    #     pass

    def test_search_user(self):
        """检测搜索用户是否正确"""
        author = '彭振宇'
        module = '用户管理'
        result = self.run.search_user('刘菲菲')
        self.assertEqual(result,'刘菲菲')

    @ddt.file_data(TestData_dir + 'search_role.json')
    def test_add_role(self,**kwargs):
        """检测新增用户是否成功"""
        author = '彭振宇'
        module = '角色管理'
        result = self.run.add_role(kwargs.get('name'),kwargs.get('des'))
        self.assertEqual('success',result)

    def test_search_role(self):
        """检测查询新增角色是否正确"""
        author = '彭振宇'
        module = '角色管理'
        result,status_code,content = self.run.search_role('老板')
        self.assertEqual(result,'老板')

    @ddt.file_data(TestData_dir + 'search_role.json')
    def test_alter_role(self,**kwargs):
        """检测修改角色描述是否正确"""
        author = '彭振宇'
        module = '角色管理'
        result = self.run.alter_role(kwargs.get('id'),kwargs.get('name'),kwargs.get('des'))
        self.assertEqual('',result)

    def test_search_stu(self):
        """检测搜索学员是否正确"""
        author = '彭振宇'
        module = '学员管理'
        res = self.run.search_stu('彭振宇')
        self.assertEqual(res,'彭振宇')




if __name__ == '__main__':
    unittest.main()